#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

// 编号映射抢到的红包数和收入
map<int, pair<int, int>> arr;

bool mycompare(pair<int, pair<int, int>> p1, pair<int, pair<int, int>> p2)
{
    if (p1.second.second == p2.second.second)
    {
        // 收入相等
        if (p1.second.first == p2.second.first)
        {
            // 红包数相等
            // 序号降序
            return p1.first < p2.first;
        }
        // 红包数降序
        return p1.second.first > p2.second.first;
    }
    // 收入降序
    return p1.second.second > p2.second.second;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int num;
        cin >> num;
        int total = 0;
        for (int j = 0; j < num; j++)
        {
            int iid, money;
            cin >> iid >> money;
            total += money;
            arr[iid].second += money;
            arr[iid].first++;
        }
        arr[i].second -= total;
    }
    vector<pair<int, pair<int, int>>> v(arr.begin(), arr.end());
    sort(v.begin(), v.end(), mycompare);
    for (int i = 0; i < v.size(); i++)
    {
        double money = v[i].second.second / 100.0;//分化元
        cout << fixed << setprecision(2) << v[i].first << " " << money;
        if (i != v.size() - 1)
        {
            cout << endl;
        }
    }
    return 0;
}